<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改密码</title>
<script language="javascript" src="<?=public_js_path();?>jquery.js">
</script>
<script language="javascript">
$(document).ready(function() {
	$("input").not("#submit_button").blur( function () {
		eval("chk_"+this.id+"()");
	});
	$("#submit_button").click( function () {
		var old_pwd_tag = $("#old_pwd_tag").html();
		var new_pwd_tag = $("#new_pwd_tag").html();
		var confirm_pwd_tag = $("#confirm_pwd_tag").html();
		if( old_pwd_tag=="" && new_pwd_tag=="" && confirm_pwd_tag==""){
			var old_pwd = $("#old_pwd").val();
			var new_pwd = $("#new_pwd").val();
			var confirm_pwd = $("#confirm_pwd").val();
			modify_pwd(old_pwd,new_pwd,confirm_pwd);
			return false;
		}else{
			return false;
		}
	});
});
/**
* 验证
*/
function chk_old_pwd()
{
    var old_pwd = $("#old_pwd").val();
	old_pwd = $.trim(old_pwd);
	if(old_pwd==""){
		$("#old_pwd_tag").html("旧密码不能为空！");
		return false;
	}else{
		$("#old_pwd_tag").html("");
		return true;
	}
}
function chk_new_pwd()
{
    var new_pwd = $("#new_pwd").val();
	new_pwd = $.trim(new_pwd);
	if(new_pwd==""){
		$("#new_pwd_tag").html("新密码不能为空！");
		return false;
	}else{
		$("#new_pwd_tag").html("");
		return true;
	}
}
function chk_confirm_pwd()
{
    var confirm_pwd = $("#confirm_pwd").val();
	confirm_pwd = $.trim(confirm_pwd);
	if(confirm_pwd==""){
		$("#confirm_pwd_tag").html("确认密码不能为空！");
		return false;
	}else{
		var new_pwd = $("#new_pwd").val();
		if( new_pwd!=confirm_pwd  ){
			$("#confirm_pwd_tag").html("新密码与确认密码不一致！");
			return false;
		}else{
			$("#confirm_pwd_tag").html("");
			return true;
		}
	}
}
function modify_pwd(old_pwd,new_pwd,confirm_pwd){
	$("#pwd_info").html("<img src='<?=img_path();?>ajaxloading.gif' border=0 />已发送请求,请等待!");
	$.ajax({
		type: "POST",
		url: "<?=site_url(array('user','modify_pwd'));?>",
		data: "old_pwd="+old_pwd+"&new_pwd="+new_pwd+"&confirm_pwd="+confirm_pwd,
		success: function(str){
			str = jQuery.parseJSON(str);
			if( str.status==1 ){
				alert(str.info);
				$("#pwd_info").html('');
				return false;
			}else{
				alert(str.info);
				$("#pwd_info").html('');
				return false;
			}
		}
	});
}
</script>
</head>
<body>
    <div>
        <form id="my_form" name="my_form" method="post" action="<?=site_url(array('user','modify_pwd'));?>">
          <ul class="service">
              <li class="posclear">
                  <div class="registw1 posfloatl">旧密码</div><input type="password" name="old_pwd" id="old_pwd" />
                  *<span class="red" id="old_pwd_tag">请输入旧密码</span>
              </li>
              <li><div class="registw1 posfloatl">新密码</div><input type="password" name="new_pwd" id="new_pwd" />*<span class="red" id="new_pwd_tag">请输入新密码</span></li>
              <li><div class="registw1 posfloatl">确认密码</div><input type="password" name="confirm_pwd" id="confirm_pwd" />*<span class="red" id="confirm_pwd_tag">请输入确认密码</span></li>
              <li><input id="submit_button" type="button" value="提交" />&nbsp;&nbsp;&nbsp;<span id="pwd_info" style="color:#FF0000"></span></li>
          </ul>
        </form>
    </div>
</body>
</html>
